package com.torry.edss.domain.accessor.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.torry.edss.infras.entity.MarketOverviewDO;
import com.torry.edss.domain.model.MarketOverview;
import com.torry.edss.infras.mapper.MarketOverviewMapper;
import com.torry.edss.domain.accessor.MarketOverviewAccessor;
import org.springframework.stereotype.Service;
import com.torry.boot.starter.mybatisplus.service.AccessorImpl;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author torry.wang
 * @since 2025-05-09
 */
@Service
@SuppressWarnings("DuplicatedCode")
public class MarketOverviewAccessorImpl extends AccessorImpl<MarketOverviewMapper, MarketOverviewDO, MarketOverview> implements MarketOverviewAccessor {
    @Override
    public MarketOverview toModel(MarketOverviewDO entity) {
        if (entity == null) return null;
        MarketOverview marketOverview = new MarketOverview();
        marketOverview.setDate(entity.getDate());
        marketOverview.setPrice(entity.getPrice());
        marketOverview.setUpValue(entity.getUpValue());
        marketOverview.setUpPercentage(entity.getUpPercentage());
        marketOverview.setUpCount(entity.getUpCount());
        marketOverview.setDownCount(entity.getDownCount());
        marketOverview.setFixedCount(entity.getFixedCount());
        marketOverview.setLimitUpCount(entity.getLimitUpCount());
        marketOverview.setLimitDownCount(entity.getLimitDownCount());
        marketOverview.setForeignCapital(entity.getForeignCapital());
        marketOverview.setDomesticCapital(entity.getDomesticCapital());
        marketOverview.setTransactionAmount(entity.getTransactionAmount());
        marketOverview.setContinuousPercentage(entity.getContinuousPercentage());
        marketOverview.setSealPercentage(entity.getSealPercentage());
        marketOverview.setPremiumPercentage(entity.getPremiumPercentage());
        marketOverview.setNuclearPercentage(entity.getNuclearPercentage());
        marketOverview.setMaxContinuousNum(entity.getMaxContinuousNum());
        marketOverview.setNote(entity.getNote());
        marketOverview.setId(entity.getId());
        marketOverview.setCreateTime(entity.getCreateTime());
        marketOverview.setUpdateTime(entity.getUpdateTime());
        return marketOverview;
    }

    @Override
    public MarketOverviewDO toEntity(MarketOverview model) {
        if (model == null) return null;
        MarketOverviewDO marketOverviewDO = new MarketOverviewDO();
        marketOverviewDO.setDate(model.getDate());
        marketOverviewDO.setPrice(model.getPrice());
        marketOverviewDO.setUpValue(model.getUpValue());
        marketOverviewDO.setUpPercentage(model.getUpPercentage());
        marketOverviewDO.setUpCount(model.getUpCount());
        marketOverviewDO.setDownCount(model.getDownCount());
        marketOverviewDO.setFixedCount(model.getFixedCount());
        marketOverviewDO.setLimitUpCount(model.getLimitUpCount());
        marketOverviewDO.setLimitDownCount(model.getLimitDownCount());
        marketOverviewDO.setForeignCapital(model.getForeignCapital());
        marketOverviewDO.setDomesticCapital(model.getDomesticCapital());
        marketOverviewDO.setTransactionAmount(model.getTransactionAmount());
        marketOverviewDO.setContinuousPercentage(model.getContinuousPercentage());
        marketOverviewDO.setSealPercentage(model.getSealPercentage());
        marketOverviewDO.setPremiumPercentage(model.getPremiumPercentage());
        marketOverviewDO.setNuclearPercentage(model.getNuclearPercentage());
        marketOverviewDO.setMaxContinuousNum(model.getMaxContinuousNum());
        marketOverviewDO.setNote(model.getNote());
        marketOverviewDO.setId(model.getId());
        marketOverviewDO.setCreateTime(model.getCreateTime());
        marketOverviewDO.setUpdateTime(model.getUpdateTime());
        return marketOverviewDO;
    }

    @Override
    public MarketOverview getByDate(String date) {
        return this.getOne(new LambdaQueryWrapper<MarketOverviewDO>().eq(MarketOverviewDO::getDate, date));
    }
}
